using System;
using System.Collections.Generic;
using System.Text;

namespace Ltf.Diffs.Diff3Docs.CommonBase
{
	public class FullViewRight : DiffDocument
	{
		public FullViewRight(string fileName)
			: base(fileName) { }

		public override void LoadResults(Diff3Results results)
		{
			// showing base and server changes - added lines to keep in sync with local
			// main file based on server file.
			int blankLineOffset = 0;
			foreach (Diff3Results.Diff3Hunk hunk in results.Hunks)
			{
				bool insertOffSetAdj = hunk.LocalRange.IsAdd ? false : true;
				LineState insertLineState = hunk.LocalRange.IsAdd ? LineState.Deleted : LineState.ChangedFrom;
				LineState markLineState = hunk.BaseRange.IsAdd ? LineState.Inserted : LineState.ChangedTo;
				int paddLines = Math.Max(hunk.LocalRange.LineCount, hunk.ServerRange.LineCount) + hunk.BaseRange.LineCount;

				if (hunk.IsServerDiff)
				{
					markLineState = LineState.SyncOnly;
				}

				if (!hunk.BaseRange.IsAdd && !hunk.IsServerDiff)
					paddLines -= InsertChanges(hunk.LocalRange.From, insertLineState, hunk.BaseLines, ref blankLineOffset, insertOffSetAdj);

				if (!hunk.LocalRange.IsAdd)
					paddLines -= MarkChanges(hunk.LocalRange.From, markLineState, hunk.LocalRange.Interval, blankLineOffset, true);

				if (!hunk.IsDeletion)
					InsertMarkedPadding(hunk.LocalRange.To, LineState.SyncOnly, paddLines, ref blankLineOffset, false);

			}

		}
	}
}

